package com.example.addview;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity {
    TextView textView;
    Button buttonReset, buttonAdd, buttonSubtract;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main);

        textView = findViewById(R.id.textView);
        buttonReset = findViewById(R.id.buttonReset);
        buttonAdd = findViewById(R.id.buttonAdd);
        buttonSubtract = findViewById(R.id.buttonSubtract);
    }

    public void onResetClick(View v) {
        textView.setText("0");
    }

    public void onAddClick(View v) {
        int currentValue = Integer.parseInt(textView.getText().toString());
        textView.setText(String.valueOf(currentValue + 1));
    }

    public void onSubtractClick(View v) {
        int currentValue = Integer.parseInt(textView.getText().toString());
        textView.setText(String.valueOf(currentValue - 1));
    }
}